package com.tanhua.model.vo;

import com.tanhua.model.db.UserInfo;
import com.tanhua.model.mongo.Sound;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class SoundVO {
    private Long id; //用户id
    private String avatar; //头像
    private String nickname; //昵称
    private String gender; //性别

    private Integer age;  //年龄
    private String soundUrl; //音频URL
    private Integer remainingTimes; //剩余次数


    public static SoundVO init(UserInfo userInfo, Sound item, int remainingTimes) {
        SoundVO vo = new SoundVO();
        //copy用户属性
        BeanUtils.copyProperties(userInfo, vo);
        //设置音频属性
        vo.setSoundUrl(item.getSoundUrl());
        //设置剩余次数
        vo.setRemainingTimes(remainingTimes);
        return vo;
    }
}
